package com.lian.servlet;

import com.lian.dao.impl.productdaoimpl;
import com.lian.dao.impl.staffdaoimpl;
import com.lian.dao.impl.userdaoimpl;
import com.lian.dao.productdao;
import com.lian.dao.staffdao;
import com.lian.dao.userdao;
import com.lian.entity.product;
import com.lian.entity.work;
import com.lian.service.impl.workserviceimpl;
import com.lian.service.workservice;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by lenovo on 2018/8/8.
 */
public class updServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        workservice ser=new workserviceimpl();
        int workid=Integer.parseInt(request.getParameter("workid"));
        work w=ser.findworkid(workid); //修改时根据id得到值

        //查询出全部
        productdao dao=new productdaoimpl();
        request.setAttribute("all",dao.findpro());

        product p=dao.findBy(w.getWpid());//查询到净水器的id与work表id联系起来

        //查询安装员的全部
        userdao dao2=new userdaoimpl();
        request.setAttribute("allus",dao2.find());//安装员
        //查询出选中tr的安装员id
        staffdao dao3=new staffdaoimpl();
       int uesrid= dao3.FindByStaffid(workid);
        request.setAttribute("uesrid",uesrid);
        request.setAttribute("wl", w);
        request.setAttribute("pl",p);
        request.getRequestDispatcher("showupd.jsp").forward(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
